
const { ccclass, property } = cc._decorator;

import QuDou from "./QuDou";
import MianMo from "./MianMo";
@ccclass
export default class StepOne extends cc.Component {
    //触摸区域
    @property(cc.Node)
    bg: cc.Node = null;
    //第一步
    //祛痘
    @property(QuDou)
    QuDou: QuDou = null;
    //面膜
    @property(MianMo)
    MianMo: MianMo = null;

    _point = 1;
    onLoad() {
        this.bg.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
        this.bg.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
        this.bg.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
    };

    onTouchStart(event) {
        switch (this._point) {
            case 1:
                this.QuDou._touchStart(event);
                break;
            case 2:
                this.MianMo._touchStart(event);
                break;
        }
    };

    onTouchMove(event) {
        switch (this._point) {
            case 1:
                this.QuDou._touchMove(event);
                break;
            case 2:
                this.MianMo._touchMove(event);
                break;
        }
    };

    onTouchEnd(event){
        switch (this._point) {
            case 2:
                this.MianMo._touchEnd(event);
                break;
        }
    };

    //更新步骤
    updatePoint(point: number) {
        this._point = point;
        this.QuDou.node.active = point == 1;
        this.MianMo.node.active = point == 2;
        switch (point) {
            case 1:
                this.QuDou.initData();
                break;
            case 2:
                this.MianMo.initData();
                break;
        }
    };


}
